﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using 晨曦超市管理系统.主页面;

namespace 晨曦超市管理系统.客户信息
{
    public partial class Modification : Form
    {
        public DataGridViewRow dr;
        public Modification()
        {
            InitializeComponent();
        }

        private void Modification_Load(object sender, EventArgs e)
        {
            //获取当前行的值，在前面一个界面我已经获取行了
            textBox1.Text = dr.Cells[0].Value.ToString();
            textBox2.Text = dr.Cells[1].Value.ToString();
            textBox3.Text = dr.Cells[2].Value.ToString();
            textBox4.Text = dr.Cells[3].Value.ToString();
            textBox5.Text = dr.Cells[4].Value.ToString();
            textBox6.Text = dr.Cells[5].Value.ToString();
            textBox7.Text = dr.Cells[6].Value.ToString();
            textBox8.Text = dr.Cells[7].Value.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (dr != null)
            {
                //取值
                string ID = dr.Cells[0].Value.ToString();
                //负值
                string SupplierID = textBox1.Text.Trim().ToString();
                string Name = textBox2.Text.Trim().ToString();
                string Linkman = textBox3.Text.Trim().ToString();
                string Phone = textBox4.Text.Trim().ToString();
                string ContactAddress = textBox5.Text.Trim().ToString();
                string CardDoorBank = textBox6.Text.Trim().ToString();
                string BankAccount = textBox7.Text.Trim().ToString();
                string Remark = textBox8.Text.Trim().ToString();
                string sqlstr = "update ProfferBill set SupplierID='" + SupplierID + "',Name='" + Name + "',Linkman='" + Linkman + "',Phone='" + Phone + "',ContactAddress='" + ContactAddress + "',CardDoorBank='" + CardDoorBank + "',BankAccount='" + BankAccount + "',Remark='" + Remark + "'   where SupplierID='" + ID + "'";
                bool duicuo = DBHelper.QEX(sqlstr);
                if (duicuo)
                {
                    MessageBox.Show("修改成功");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("修改错误");
                }
             }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label5_Click(object sender, EventArgs e)
        {

        }
    }
}
